<template>
  <div class="grid_cont">
    <div style="background: #fff; padding: 16px 16px 0 16px">
      <div style="display: flex; margin-bottom: 20px">
        <div style="width: 3px; height: 18px; background-color: rgba(204, 53, 47, 1)"></div>
        <div style="margin-left: 10px; font-size: 15px; line-height: 16px">公告详情</div>
      </div>
      <el-form :model="formParams" style="margin-left: 14px" label-width="140px">
        <el-form-item label="公告分类：" prop="announcementType">
          <el-input
            v-model="formParams.announcementType"
            placeholder=""
            placement="bottom"
            style="max-width: 730px"
            disabled
          />
        </el-form-item>
        <el-form-item label="标题：" prop="topic">
          <el-input v-model="formParams.topic" style="max-width: 730px" disabled />
        </el-form-item>
        <el-form-item label="正文：" prop="content">
          <div style="max-width: 730px; text-align: left">
            <div class="introducestyle">
              <Editor
                v-model="formParams.content"
                style="max-width: 730px; cursor: not-allowed"
                :editor-config="editorConfig"
              />
            </div>
          </div>
        </el-form-item>
        <div class="flex">
          <div style="cursor: not-allowed">
            <el-form-item label="附件：" prop="files">
              <UploadFile
                :is-show-tip="false"
                v-model="formParams.files"
                :limit="1"
                type="yaoWen"
                :disabled="true"
              />
            </el-form-item>
          </div>
          <div class="upload-tip"
            >最多可上传10个，小于100MB，仅支持doc、docx、xls、xlsx、ppt、pptx、pdf、txt、zip类型文件</div
          >
        </div>
      </el-form>
    </div>
  </div>
  <div class="grid_cont2">
    <el-button class="grid_btn" @click="detailsbtn">返回</el-button>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import * as getNoticeApi from '@/api/noticeAnnouncement/index'
import globalApi from '@/api/spb/global'
const { push } = useRouter() // 路由
const route = useRoute()
const treeData = ref([])
const editorConfig = ref({
  MENU_CONF: {},
  readOnly: readonly
})
const formParams = reactive({
  announcementType: 1,
  topic: '',
  content: '',
  files: ''
})
/** 返回 */
const detailsbtn = () => {
  push({
    name: 'noticeAnnouncement'
  })
}
/** 获取分类列表 */
const getDictData = () => {
  const params = {
    pageNo: 1,
    pageSize: 100,
    dictType: 'countryside_announcement_type'
  }
  globalApi.getDictData(params).then((res) => {
    treeData.value = res.list
  })
}
const detailType = (val) => {
  let content = ''
  if (treeData.value) {
    treeData.value.forEach((t) => {
      if (t.value == val) {
        content = t.label
      }
    })
  }
  return content
}
const getAnnouncementDetail = () => {
  getNoticeApi.getNoticeDetail(route.query.id).then((res) => {
    formParams.topic = res.topic
    formParams.content = res.content
    formParams.announcementType = detailType(res.announcementType)
    formParams.files = res.fileDOList
  })
}

onMounted(() => {
  getDictData()
  getAnnouncementDetail()
})
</script>
<style scoped>
.grid_cont {
  min-height: 600px;
  background: #fff;
}

.grid_cont2 {
  width: 100%;
  background: #fff;
  height: 65px;
  justify-content: center;
  align-items: center;
  display: flex;
  padding: 0;
  box-shadow: 0px -2px 6px 0px rgba(188, 188, 188, 0.65);
}

.grid_btn {
  width: 80px;
  height: 30px;
  background-color: #ff9900;
  border: none;
  color: #fff;
}

.grid_btn:hover {
  opacity: 0.8;
}

::v-deep .el-cascader .el-input.is-focus .el-input__wrapper {
  box-shadow: 0 0 0 1px #cc352f !important;
}

.introducestyle {
  box-shadow: 0 0 0 1px var(--el-disabled-border-color);
  border-radius: 4px;
  background: transparent !important;
}
.introducestyle::selection {
  box-shadow: 0 0 0 1px #cc352f !important;
}

::v-deep .w-e-text-placeholder {
  top: 10px;
  text-align: justify;
  width: 96%;
}

::v-deep .w-e-bar {
  background: transparent !important;
}

::v-deep .w-e-text-container {
  background: transparent !important;
}

::v-deep .w-e-bar {
  box-shadow: 0px 1px 0px 0px var(--el-disabled-border-color);
  pointer-events: none;
  cursor: not-allowed;
  background: var(--el-disabled-bg-color) !important;
}

::v-deep .border-solid {
  border-color: var(--el-disabled-bg-color);
  border-radius: 4px;
}

:deep(.w-e-text-container [data-slate-editor] img) {
  cursor: not-allowed !important;
}

:deep(.w-e-text-container [data-slate-editor]) {
  background: var(--el-disabled-bg-color) !important;
}

::v-deep .upload .el-upload .el-upload-dragger {
  border: 1px solid var(--el-border-color-darker) !important;
}

::v-deep .upload .el-upload .el-upload-dragger:hover {
  border: 1.5px solid #ccc !important;
}

.btnhover:hover {
  opacity: 0.8;
}
:deep(.w-e-text-container [data-slate-editor] p) {
  color: #a8abb2;
}
.upload-tip {
  line-height: 32px;
  color: rgba(142, 142, 142, 1);
  font-size: 14px;
  text-align: left;
  margin-left: 20px;
  margin-bottom: 10px;
}
:deep(.el-button--primary) {
  cursor: not-allowed;
}
:deep(.el-button--primary:hover) {
  cursor: not-allowed;
  background: #409eff;
  color: #fff;
}
</style>
